package com.tansun.easycare.ruleDimensioninfo.action;

import com.jeedev.msdp.base.web.BaseAction;
import com.jeedev.msdp.base.web.ResponseVO;
import com.tansun.easycare.ruleDimensioninfo.service.IRuleDimensioninfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/ruleDimensioninfo")
@Api(tags = "ruleDimensioninfo")
@Slf4j
public class RuleDimensioninfoAction extends BaseAction {

    @Autowired
    private IRuleDimensioninfoService ruleDimensioninfoService;


    /**
    * @功能描述:分页查询
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/findRuleDimensioninfoPage",method = RequestMethod.POST)
    @ApiOperation(value = "分页查询")
    public ResponseVO findRuleDimensioninfoPage(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleDimensioninfoService.findPage(params);
    }
    /**
    * @功能描述:新增或修改一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
    @ApiOperation(value = "新增或修改一条记录")
    public ResponseVO insertOrUpdate(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
    if(params == null) {
        return this.createResponse(null, ResponseVO.ERROR, "参数不能为空!");
    }
        String id = (String)params.get("id");
        if(null == id || "".equals(id)) {
        return ruleDimensioninfoService.insert(params);
    }else {
        return ruleDimensioninfoService.updateById(params);
    }
}


    /**
    * @功能描述:根据主键ID删除一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/deleteRuleDimensioninfoById", method = RequestMethod.POST)
    @ApiOperation(value = "根据主键ID删除一条记录")
    public ResponseVO deleteRuleDimensioninfoById(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleDimensioninfoService.deleteById(params);
    }

    /**
    * @功能描述:根据主键ID查询一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/selectRuleDimensioninfoById", method = RequestMethod.POST)
    @ApiOperation(value = "根据主键ID查询一条记录")
    public ResponseVO selectRuleDimensioninfoById(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleDimensioninfoService.selectById(params);
    }

}
